<?php

abstract class Home_Dao_Base extends My_Connection_Pdo
{
    protected static $_dbConfigFileName = "db";

    public function __construct()
    {
        $config = My_Config::getInstance()->getConfig(self::$_dbConfigFileName);
        if (!isset($config['slave'])) $config['slave'] = $config['master'];
        parent::__construct($config);
    }

    function insert(array $data, $tableName = null)
    {
        if (isset($data['content'])) $data['content'] = My_Tool::removeXss($data['content']);
        if (isset($data['title'])) $data['title'] = My_Tool::removeXss($data['title']);
        return parent::insert($data, $tableName);
    }

    function update(array $data, $where = array(), $tableName = null)
    {
        if (isset($data['content'])) $data['content'] = My_Tool::removeXss($data['content']);
        if (isset($data['title'])) $data['title'] = My_Tool::removeXss($data['title']);
        return parent::update($data, $where, $tableName);
    }

}